package cn.edu.tju.wallet.repository;

import cn.edu.tju.wallet.domain.WithdrawRule;
import cn.edu.tju.wallet.domain.WithdrawRule.RuleStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * 提现规则Repository接口
 */
@Repository
public interface WithdrawRuleRepository extends JpaRepository<WithdrawRule, Long> {

    /**
     * 查询所有激活的提现规则
     * @return 提现规则列表
     */
    List<WithdrawRule> findByStatus(RuleStatus status);

    /**
     * 查询当前激活的提现规则（假设只有一条）
     * @return 提现规则
     */
    Optional<WithdrawRule> findFirstByStatusOrderByIdDesc(RuleStatus status);
}

